package press.bolin.game;

import java.awt.*;

public abstract class GameObject {

    // point
    private int x;
    private int y;

    // 图片
    private Image img;

    // 速度
    private int speed;


    // 游戏界面
    private GameFrame gameFrame;

    public GameObject(GameFrame gameFrame) {
        this.gameFrame = gameFrame;
    }

    public GameObject(int x, int y, GameFrame gameFrame) {
        this.x = x;
        this.y = y;
        this.gameFrame = gameFrame;
    }

    /**
     * 获取游戏矩形
     * @return
     */
    public abstract Rectangle getRec();

    /**
     * 绘制自己
     * @param g
     */
    public abstract  void paintSelf(Graphics g);

    public Image getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = Toolkit.getDefaultToolkit().getImage(img);
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public GameFrame getGameFrame() {
        return gameFrame;
    }

    public void setGameFrame(GameFrame gameFrame) {
        this.gameFrame = gameFrame;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }
}
